home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / QuickDraw / Virtual Sphere 1.0.1 / Virtual Sphere Sample Code 1.1 / Globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  4.1 KB  |  127 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2. /* Globals.c
  3. /*
  4. /* Author: Michael Chen, Human Interface Group / ATG
  5. /* Copyright © 1991-1993 Apple Computer, Inc.  All rights reserved.
  6. /*
  7. /* Part of Virtual Sphere Sample Code Release v1.1
  8. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  9.  
  10. #ifndef __GLOBALS__
  11. #include "Globals.h"
  12. #endif
  13.  
  14. #ifndef __DIALOGS__
  15. #include <Dialogs.h>
  16. #endif
  17.  
  18. #ifndef __SEGLOAD__
  19. #include <SegLoad.h>
  20. #endif
  21.  
  22. # include "Sample.h"
  23.  
  24. /* Declare globals used in menus */
  25. short        gObjectDisplayed;            /* Which object is being draw currently */                
  26. short        gRenderingStyle;            /* iLineDrawing, iFlatShading, iFlatShadingWithOutline */                
  27. Boolean        gDoBackfacedPolygonRemoval;
  28. Boolean        gDoubleBuffer;
  29. Boolean        gDrawInColor;
  30.  
  31.  
  32. /*=================================================================================================
  33. /* DebugMessage
  34. /*
  35. /* Show a debugging message either to the debugger or in a dialog box
  36. /* depending if the code is compiled for debugging (qDebug flag).
  37. /*-------------------------------------------------------------------------------------------------*/
  38. pascal void DebugMessage (Str255 message)
  39. {
  40.     if (qDebug) {
  41.         DebugStr (message);
  42.     } else {
  43.         MessageAlert (message);
  44.     }
  45. }
  46.  
  47. /*=================================================================================================
  48. /* EnableDisableItem
  49. /*
  50. /* Single routine to call EnableItem or DisableItem
  51. /*-------------------------------------------------------------------------------------------------*/
  52. pascal void EnableDisableItem (MenuHandle theMenu, short item, Boolean enable)
  53. {
  54.     if (enable) {
  55.         EnableItem (theMenu, item);
  56.     } else {
  57.         DisableItem (theMenu, item);
  58.     }
  59. }
  60.  
  61. /*=================================================================================================
  62. /* LocalToGlobalRect
  63. /*
  64. /* Returns a rect in global coordinate
  65. /* Note the implicit dependency on the ordering of fields within a Rect
  66. /*-------------------------------------------------------------------------------------------------*/
  67. pascal void LocalToGlobalRect (Rect *globalRect)
  68. {
  69.     LocalToGlobal ((Point *) &(globalRect->top));
  70.     LocalToGlobal ((Point *) &(globalRect->bottom));
  71. }
  72.  
  73. /*=================================================================================================
  74. /* MessageAlert
  75. /*
  76. /* Put up a message in an alert
  77. /* Routine must be universal code
  78. /*-------------------------------------------------------------------------------------------------*/
  79. #ifdef applec
  80. #pragma push                    /* MPW: save compiler flags         */
  81. #pragma processor 68000            /* Generate 68000 instructions only */
  82. #endif
  83. pascal void MessageAlert (Str255 message)
  84. {
  85.     #ifdef THINK_C                /* THINK C: Generate 68020 instructions… */
  86.     #pragma options(!mc68020)    /* …NOT!  Silly way of saying 68000      */
  87.     #endif                        /* instructions only.  Note this pragma  */
  88.                                 /* is defined only until end of routine. */
  89.     SetCursor(&qd.arrow);
  90.     ParamText (message, "", "", "");
  91.     SysBeep (10);
  92.     (void) Alert (rMessageAlert, nil);
  93. }
  94. #ifdef applec
  95. #pragma pop                        /* MPW: restore compiler flags */
  96. #endif
  97.  
  98. /*=================================================================================================
  99. /* MessageAlertAndQuit
  100. /*
  101. /* Put up a message in an alert then quit out of application
  102. /* Routine must be universal code
  103. /*-------------------------------------------------------------------------------------------------*/
  104. #ifdef applec
  105. #pragma push                /* make sure error dialogs can be executed on all machines */
  106. #pragma processor 68000
  107. #endif
  108. pascal void MessageAlertAndQuit (Str255 message)
  109. {
  110.     MessageAlert (message);
  111.     ExitToShell();
  112. }
  113. #ifdef applec
  114. #pragma pop
  115. #endif
  116.  
  117. /*=================================================================================================
  118. /* ScreenDepth
  119. /*
  120. /* Return the maximum monitor depth in the enclosing globalRect
  121. /*-------------------------------------------------------------------------------------------------*/
  122. pascal short ScreenDepth (const Rect *globalRect)
  123. {
  124.     GDHandle maxGDevice;
  125.     maxGDevice = GetMaxDevice (globalRect);
  126.     return ((**(**maxGDevice).gdPMap).pixelSize);
  127. }